
    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>重载和重写的区别，以及方法的返回值是否能作为判断重载的条件。 - 学习卡片</title>
      <style>
        body { font-family: sans-serif; background-color: #f0f8ff; color: #333; display: flex; flex-direction: column; align-items: center; padding: 50px 20px; }
        .header h1 { font-size: 32px; }
        .grid-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; width: 100%; max-width: 1200px; }
        .card-container { perspective: 1200px; cursor: pointer; height: 250px; }
        .card { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.7s; border-radius: 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
        .card-container.flipped .card { transform: rotateY(180deg); }
        .card-face { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; display: flex; flex-direction: column; box-sizing: border-box; border-radius: 16px; background-color: #fff; padding: 24px; }
        .card-back { background-color: #f0fff4; transform: rotateY(180deg); justify-content: space-between; }
        .card-category { font-size: 14px; color: #0052d9; margin-bottom: 8px; font-weight: 500; }
        .card-question { font-size: 20px; font-weight: 500; flex-grow: 1; display: flex; align-items: center; justify-content: center; text-align: center; }
        .card-answer-wrapper { flex-grow: 1; overflow-y: auto; }
        .card-answer { font-size: 15px; line-height: 1.7; }
        .card-footer { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 16px; margin-top: 16px; }
        .card-source { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 12px; margin-top: 12px; }
      </style>
    </head>
    <body>
      <div class="header">
        <h1>重载和重写的区别，以及方法的返回值是否能作为判断重载的条件。 - 学习卡片</h1>
      </div>
      <div class="grid-container">
        
    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">概念</div>
          <div class="card-question">在Java中，什么是方法重载 (Overloading)？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">概念</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">重载 (Overloading) 是指在同一个类中定义多个名称相同但参数列表不同的方法。参数列表的不同可以体现在参数的类型、数量或顺序上。</div>
          </div>
          <div class="card-source">来源: 1. 重载（Overloading）</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">概念</div>
          <div class="card-question">在Java中，什么是方法重写 (Overriding)？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">概念</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">重写 (Overriding) 是指在子类中对父类已有的方法进行重新定义。重写的方法必须与父类中被重写的方法具有相同的方法名、参数列表，以及兼容的返回值类型。</div>
          </div>
          <div class="card-source">来源: 2. 重写（Overriding）</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">规则</div>
          <div class="card-question">为什么仅有返回值类型不同，不足以构成方法重载？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">规则</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">因为Java编译器是通过方法签名（方法名称和参数列表）来区分方法的，方法签名不包括返回值类型。如果两个方法仅有返回值不同而方法签名相同，编译器将无法区分它们，从而导致编译错误。</div>
          </div>
          <div class="card-source">来源: 3. 返回值是否能作为判断重载的条件</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">方法重写 (Overriding) 对访问修饰符有什么限制？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">子类重写方法的访问修饰符不能比父类方法的更严格，但可以更宽松。例如，如果父类方法是 protected，子类重写后可以是 protected 或 public，但不能是 private。</div>
          </div>
          <div class="card-source">来源: 2. 重写（Overriding）</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">方法重写 (Overriding) 时，对返回值类型有什么要求？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">重写方法的返回值类型必须与父类方法的返回值类型相同，或者是其子类型。后者被称为“协变返回类型”。</div>
          </div>
          <div class="card-source">来源: 2. 重写（Overriding）</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">比较</div>
          <div class="card-question">重载 (Overloading) 和重写 (Overriding) 在发生范围上有什么核心区别？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">比较</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">重载发生在同一个类中，是类内部多态性的体现。而重写发生在具有继承关系的子类和父类之间，是运行时多态性的基础。</div>
          </div>
          <div class="card-source">来源: 1. 重载（Overloading）和 2. 重写（Overriding）</div>
        </div>
      </div>
    </div>

      </div>
    </body>
    </html>
